package com.hyd.project;
import com.hyd.util.LoginUtil;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.Toast;

/**
 * 展示个人信息界面
 * 
 * @author llf
 * 
 */
public class PersonalInfoActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_personal_info);
	}
	
	//跳到编辑个人信息的界面
	public void edit(View v){
		Intent intent = new Intent(PersonalInfoActivity.this,EditPersonalInfoActivity.class);
		startActivity(intent);
		overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
	}
	// 退出当前账号
	public void logout(View v) {
		final AlertDialog.Builder bulider = new AlertDialog.Builder(
				PersonalInfoActivity.this);
		bulider.setTitle("退出当前账户");
		bulider.setMessage("确认退出?");
		bulider.setPositiveButton("退出", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				LoginUtil.LoginOut(PersonalInfoActivity.this);
				Toast.makeText(PersonalInfoActivity.this, "注销成功",
						Toast.LENGTH_SHORT).show();
				finish();
				overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
			}
		});

		bulider.setNegativeButton("取消", new DialogInterface.OnClickListener() {

			@Override
			public void onClick(DialogInterface dialog, int which) {
				bulider.create().dismiss();
			}
		});
		bulider.create().show();
	}
	
	//退出当前Activity
	public void back(View v){
		finish();
		overridePendingTransition(android.R.anim.slide_in_left, android.R.anim.slide_out_right);
	}
}
